
import { Injector } from "./app_base/base/utils/Injector";
import { app } from "./base";
import { CocosApp } from "./CocosApp";
import { CocosNativeHelper } from "./app_cocos/native/CocosNativeHelper";
import ProtocolHelper from "./app_cocos/net/socket/ProtocolHelper";

import { TimerImpl } from "./app_cocos/tick/TickManagerImpl";

import { viewClass } from "./app_cocos/View/CCPViewLoader";
import { BootScene } from "./BootScene";
import { Application } from "./app_base/base/Application";
import { PublisherManager } from "./app_base/module/publisher/PublisherManager";

const { ccclass, executionOrder } = cc._decorator;
@ccclass
// @executionOrder(-1)
export class Boot extends cc.Component {
    protected onEnable(): void {
        Injector.inject(Application.KEY, CocosApp);

        app.App.launch({
            injects: [ProtocolHelper, PublisherManager]
        });
        this._init();

        this._enableBoot();
    }

    private _init(): void {
        //初始化分发平台
        // app.publisher.enable();//启用相应的平台功能
        // app.publisher.publisher.initSDK();//调用平台初始化接口

        //初始化基础事务
        // app.businessCenter.init();
        app.storage.setCache(true);
    }

    private _enableBoot() {
        viewClass({ path: "MainRes://view/tips/Tips", viewClassName: "TipsView", cache: true })();

        //启动场景
        let bootScene: BootScene = this.node.getComponent(BootScene);
        bootScene.setData();
    }
}